<template>
  <div>
    <p v-if="['0', '2'].includes(trackstatus)" class="status">
      <span class="icon icon-xuanzhong"></span>
      <span class="mid">已追踪，请至</span>
      <span>"我的"</span>
      <span>页面查看</span>
    </p>
    <p v-if="trackstatus === '1'" class="status">
      <span>追踪失败</span>
    </p>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { saveFeeds } from '@/api/home'
import sensormixin from '@/mixins'
export default {
  props: ['fields', 'filterData', 'trackParame', 'detailsIstracked', 'overlapingItem'],
  mixins: [sensormixin],
  data() {
    return {
      trackstatus: '0'
    }
  },
  methods: {
    async savetracklist() {
      try {
        const data = await saveFeeds(this.trackParame)
        if (['0', '2'].includes(data.value.addFlag)) {
          this.$emit('handleTrackButtonIn')
        }
        this.trackstatus = data.value.addFlag
      } catch (err) {
        this.trackstatus = '1'
      }
      // 增加创建追踪埋点
      this.createTraceForSensor()
    }
  },
  computed: {
    ...mapGetters(['userInfo', 'ticket'])
  },
  created() {
    this.savetracklist()
  }
}
</script>

<style lang="scss" scoped>
.status {
  text-align: center;
  padding-bottom: 20px;
  font-size: 16px;
  line-height: 18px;
  .mid {
    margin-left: 6px;
  }
}
</style>
